#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

int		menu_event()
{
  SDL_Event	event;
  int		i;

  i = 0;
  while (i == 0)
    {
      SDL_PollEvent(&event);
      if(event.type == SDL_KEYDOWN)
	{
	  if (event.key.keysym.sym == SDLK_ESCAPE)
	    i = 1;
	  if (event.key.keysym.sym == SDLK_RETURN)
	    i = 2;
	}
    }
  return (i);
}

int		menu_Cgraph()
{
  int		i;
  SDL_Surface	*ecran;
  SDL_Surface	*fond;
  SDL_Rect	position;

  position.x = 0;
  position.y = 0;
  SDL_Init(SDL_INIT_VIDEO);
  SDL_WM_SetCaption("Zappy GraphX", NULL);
  ecran = SDL_SetVideoMode(1280, 720, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
  SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
  SDL_Flip(ecran);
  SDL_EnableKeyRepeat(100, 100);
  fond = IMG_Loag("./Images/Zappy_Menu.png");
  SDL_BlitSurface(fond, NULL, ecran, &position);
  i = menu_event()
  SDL_Quit();
  return (i);
}

int		main(int ac, char **av)
{
  if (ac == 3)
    {
      if (menu_Cgraph() == 1)
	exit (0);
      start_Cgraph();
    }
  else
    {
      printf("./%s [PORT] [HOST]\n", av[0]);
      exit(0);
    }
}
